class VersionListResponse {
  List<VersionItemResponse> rows;
  int total;

  VersionListResponse({
    required this.rows,
    required this.total,
  });

  factory VersionListResponse.fromJson(Map<String, dynamic> json) =>
      VersionListResponse(
        total: json['total'] as int,
        rows: (json['rows'] as List)
            .map((e) => VersionItemResponse.fromJson(e))
            .toList(),
      );
}

class VersionItemResponse {
  int? versionId;
  String? platformType;
  String? versionName;
  String? versionNo;
  String? appLink;
  double? appSize;
  String? forceFlag; // 1 强制更新 0 不强制
  List<String>? updateContentList;
  String? createTime;
  bool canUpdate;
  bool curVersion;

  VersionItemResponse({
    this.versionId,
    this.platformType,
    this.versionName,
    this.versionNo,
    this.appLink,
    this.appSize,
    this.forceFlag,
    this.updateContentList,
    this.createTime,
    this.canUpdate = false,
    this.curVersion = false,
  });

  factory VersionItemResponse.fromJson(Map<String, dynamic> json) {
    return VersionItemResponse(
      versionId: json['versionId'] as int?,
      platformType: json['platformType'] as String?,
      versionName: json['versionName'] as String?,
      versionNo: json['versionNo'] as String?,
      appLink: json['appLink'] as String?,
      appSize: json['appSize'] as double?,
      forceFlag: json['forceFlag'] as String?,
      createTime: json['createTime'] as String?,
      updateContentList:
          (json['updateContentList'] as List).map((e) => e as String).toList(),
    );
  }

  Map<String, dynamic> toJson() => {
        'versionId': versionId,
        'platformType': platformType,
        'versionName': versionName,
        'versionNo': versionNo,
        'appLink': appLink,
        'appSize': appSize,
        'forceFlag': forceFlag,
        'createTime': createTime,
        'updateContentList': updateContentList.toString(),
      };
}
